package com.gxy.learn.thread.example.abcdef;

/**
 * @description: 多线程顺序执行
 * @author: gaoxueyong
 * @Date: 2022/11/10 15:15
 */
public class ThradJoinTest {
    public static void main(String[] args) {
        test1();
//        test2();
    }
    public static void test1() {
        final Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("产品经理规划新需求");
            }
        });

        final Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    thread1.join();
                    System.out.println("开发人员开发新需求功能");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread thread3 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    thread2.join();
                    System.out.println("测试人员测试新功能");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        thread2.start();
        thread1.start();
        thread3.start();

    }
    public static void test2() {
        final Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("产品经理规划新需求");
            }
        });

        final Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                    System.out.println("开发人员开发新需求功能");
                }
        });

        Thread thread3 = new Thread(new Runnable() {
            @Override
            public void run() {
                    System.out.println("测试人员测试新功能");
            }
        });

        thread1.start();
        try{
            thread1.join();
        }catch (Exception e){
            e.printStackTrace();
        }
        thread2.start();
        try{
            thread2.join();
        }catch (Exception e){
            e.printStackTrace();
        }
        thread3.start();

    }
}
